﻿<div class="page-heading">
		<h1>Sửa khóa học</h1>
</div>
<div class="page-content">
    <div class="msg-box hidden" id="msg-newsedit">
        <span class="msg">Sửa khóa học thành công.</span>
    </div>
    <div class="error-box hidden" id="err-newsedit">
    </div>
    <form id="form" method="post" enctype="multipart/form-data">
        <input type="hidden" name="submit" value="true" />
        <input type="hidden" name="conditions" value="" />
        <input type="hidden" name="Id" value="{edit_id}" />
        <div class="admin-row">
            <div class="left"><label>Title</label></div>
            <div class="right"><input class="input" name="Name" value="{name}" type="text" /></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Tên khóa học</label></div>
            <div class="right"><input class="input" name="ViName" value="{viName}" type="text" /></div>
        </div>-->
        <div class="admin-row">
            <div class="left"><label>Prerequisites</label></div>
            <div class="right" id="Conditions">
                
            </div>
        </div>
        <div class="admin-row">
            <div class="left"><label>Level</label></div>
            <div class="right">
                <select id="level" name="level" value="{level}">
                    <option value="1">Tổng quan</option>
                    <option value="2">Nền tảng</option>
                    <option value="3">Nâng cao</option>
                    <option value="4">Chuyên ngành</option>
                </select>
            </div>
        </div>
        <div class="admin-row">
            <div class="left"><label>Duration</label></div>
            <div class="right"><input class="input" name="Duration" value="{duration}"></div>
        </div>
        <div class="admin-row">
            <div class="left"><label>Code</label></div>
            <div class="right"><input class="input" name="Code" value="{code}"></div>
        </div>
        <div class="admin-row">
            <div class="left"><label>Function</label></div>
            <div class="right"><textarea name="Function">{function}</textarea></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Chức năng QLDA</label></div>
            <div class="right"><textarea name="viFunction">{viFunction}</textarea></div>
        </div>-->
        <div class="admin-row">
            <div class="left"><label>Skills</label></div>
            <div class="right"><textarea name="Skills">{skills}</textarea></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Kĩ năng QLDA</label></div>
            <div class="right"><textarea name="viSkills">{viSkills}</textarea></div>
        </div>-->
        <div class="admin-row">
            <div class="left"><label>Description</label></div>
            <div class="right"><textarea name="Detail">{Detail}</textarea></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Mô tả</label></div>
            <div class="right"><textarea name="ViDetail" id="news_videtail">{ViDetail}</textarea></div>
        </div>-->
        <div class="admin-row">
            <div class="left"><label>Topics</label></div>
            <div class="right"><textarea name="Topics">{Topics}</textarea></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Chủ đề</label></div>
            <div class="right"><textarea name="viTopics">{viTopics}</textarea></div>
        </div>-->
        <div class="admin-row">
            <div class="left"><label>Attendees</label></div>
            <div class="right"><textarea name="Attendants">{Attendants}</textarea></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Đối tượng phù hợp</label></div>
            <div class="right"><textarea name="viAttendants">{viAttendants}</textarea></div>
        </div>-->
        <div class="admin-row">
            <div class="left"><label>Benefits</label></div>
            <div class="right"><textarea name="Benefits">{Benefits}</textarea></div>
        </div>
        <!--<div class="admin-row">
            <div class="left"><label>Lợi ích</label></div>
            <div class="right"><textarea name="viBenefits">{viBenefits}</textarea></div>
        </div>-->
        <div class="admin-row">
            <div class="left">&nbsp;</div>
            <div class="right">
                <input class="button" type="submit" value="Lưu lại" />
                <a class="button" onclick="location='{BaseUrl}/admin/news'" >Hủy bỏ</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $('#news_detail').cleditor({ width: "100%", height: "500px", docCSSFile: "{ResourceUrl}/css/editor.css" });
    $('#news_videtail').cleditor({ width: "100%", height: "500px", docCSSFile: "{ResourceUrl}/css/editor.css" });
    
    $(document).ready(function() {
        $('#level').val({level});
    });
</script>

<script>
    function remove(th) {
        $(th).parent().remove();
        $('.prerequisites').hide();
        $('.prerequisites').eq($('.prerequisites').length - 1).show();
        if ($('.prerequisites').length == 0)
            append();
    }

    function append() {
        var str = $('<select></select>');
        str.append("<option value=-1>-- Select prerequisites</option>");
        <fly:list data="view">
            str.append("<option value={view.id}>{view.title}</option>");
        </fly:list>
        var btn = $('<a onclick="append()" class="button prerequisites">Add</a>');
        var rmBtn = $('<a onclick="remove(this)" class="button rm-prerequisites">Remove</a>');
        $('.prerequisites').hide();
        return $('<div></div>').append(str).append(btn).append(rmBtn).appendTo($('#Conditions'));
    }

    (function() {
        <fly:list data="conditionView">
            var div = append();
            div.find('select').val({conditionView.id});
        </fly:list>
        append();

        $('#form').submit(function() {
            var arr = Array();
            $('#Conditions select').each(function() {
                if ($(this).val() != -1)
                    arr.push($(this).val());
            });
            $('input[name=conditions]').val(arr.join(','));
        });
    })();
</script>